
package projetocompiladores;

import java.awt.geom.AffineTransform;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D.Double;
import java.util.Collection;
import java.util.LinkedList;
import org.jhotdraw.draw.EllipseFigure;
import org.jhotdraw.draw.Figure;
import org.jhotdraw.draw.GraphicalCompositeFigure;
import org.jhotdraw.draw.LabelFigure;
import org.jhotdraw.draw.handle.DragHandle;
import org.jhotdraw.draw.handle.Handle;
import org.jhotdraw.draw.handle.MoveHandle;
import org.jhotdraw.draw.handle.ResizeHandleKit;

/**
 *
 * @author Anderson Vinicius
 */
public class LabeledEllipseFigure extends GraphicalCompositeFigure {

    public LabeledEllipseFigure(String text, 
                                Point2D.Double posicao) {
        setPresentationFigure(new EllipseFigure());
        
        LabelFigure label = new LabelFigure(text);
        
        double offsetX = posicao.x + label.getBounds().width + 20;
        double offsetY = posicao.y + label.getBounds().height + 20;
        setBounds(posicao, new Point2D.Double(offsetX, offsetY));
        
        double centerFigureX = this.getBounds().getCenterX();
        double centerLabelX = label.getBounds().getCenterX();

        label.transform(new AffineTransform(0, 0, 0, 0, centerFigureX - centerLabelX, this.getBounds().getCenterY() - label.getBounds().getCenterY()));
        
        add(label);
    }
    
}
